﻿using System.Windows.Documents;

using VSTalk.Engine.ViewModel.Messenger.History;

namespace VSTalk.Engine.ViewModel.Messenger.ThreadRenderer.BlockBuilder
{
    public class HistoryBlockBuilder
    {
        public Block CreateBlock(HistoryCommandMessage message)
        {
            var paragraph = new Paragraph();
            paragraph.Inlines.Add("Show messages from: ");
            foreach (var timeFrameParam in message.Frames)
            {
                Inline frame;
                if (timeFrameParam.Enabled)
                {
                    var hyperlink = new Hyperlink(new Run(timeFrameParam.DisplayingValue));
                    var param = timeFrameParam;
                    hyperlink.Click += (sender, args) => message.Callback(param);
                    frame = hyperlink;
                }
                else
                {
                    var disabled = new Bold(new Run(timeFrameParam.DisplayingValue));
                    frame = disabled;
                }
                paragraph.Inlines.Add(frame);
                paragraph.Inlines.Add(new Run(" "));
            }
            return paragraph;
        }
    }
}